package com.hliu.shiro.model;

import com.hliu.core.model.BaseModel;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * author: 6
 * date: 13-4-18
 */
@Entity
@Table(name = "fc_permission")
public class Permission extends BaseModel {
	private String permissionName;
	private String description;
	private List<Role> roles;

	public String getPermissionName() {
		return permissionName;
	}

	public void setPermissionName(String permissionName) {
		this.permissionName = permissionName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToMany(targetEntity = Role.class)
	@JoinTable(name = "fc_role_permission",
			joinColumns = {@JoinColumn(name = "permission_id", referencedColumnName = "id")},
			inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")})
	public List<Role> getRoles() {
		if (roles == null) {
			roles = new ArrayList();
		}
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
}
